'''
Created on 2014-6-17

@author: Administrator
'''
from django.http.response import HttpResponse
from weixin.receive.msg import process_text_msg, process_location_msg,\
    process_image_msg, process_voice_msg, process_video_msg, process_link_msg
from weixin.receive.event import process_subscribe_event, process_scan_event,\
    process_unsubscribe_event, process_location_event, process_click_event,\
    process_view_event

def proc_text(msg):
    return HttpResponse(process_text_msg(msg))

def proc_location(msg):
    return HttpResponse(process_location_msg(msg))

def proc_image(msg):
    return HttpResponse(process_image_msg(msg))

def proc_voice(msg):
    return HttpResponse(process_voice_msg(msg))

def proc_video(msg):
    return HttpResponse(process_video_msg(msg))

def proc_link(msg):
    return HttpResponse(process_link_msg(msg))

def proc_event(msg):
    eventType=msg.get("Event")
#     proc_function = getattr(comprocs,"proc_%s"%eventType)
    proc_function = globals()["proc_%s"%eventType]
    if callable(proc_function):
        return proc_function(msg)
    else:
        return HttpResponse("EVENT ERROR")
#event_proc
def proc_subscribe(msg):
    return HttpResponse(process_subscribe_event(msg)) 

def proc_unsubscribe(msg):
    return HttpResponse(process_unsubscribe_event(msg)) 

def proc_SCAN(msg):
    return HttpResponse(process_scan_event(msg))  

def proc_LOCATION(msg):
    return HttpResponse(process_location_event(msg)) 

def proc_CLICK(msg):
    return HttpResponse(process_click_event(msg)) 

def proc_VIEW(msg):
    return HttpResponse(process_view_event(msg)) 


